//
//  JWShowMeViewController.m
//  见闻新闻
//
//  Created by brother on 16/3/14.
//  Copyright © 2016年 JoanBoat. All rights reserved.
//

#import "JWShowMeViewController.h"

#import <MJExtension.h>

#import "JWUserModel.h"

#import "JWshowMeCell.h"

#import "JWShowMeTableViewCell.h"

#import "JWUpLoadImageViewController.h"

#import "JWModeifyNickNameViewController.h"

#import "JWModifyPassWordViewController.h"

#import "JWUpUserDataTools.h"

@interface JWShowMeViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *showMeTableView;

@property (nonatomic,strong) NSMutableDictionary *dict;

@property (weak, nonatomic) IBOutlet UITableView *mtTableView;

@property (strong,nonatomic)MBProgressHUD *HUD;

@end

@implementation JWShowMeViewController


-(void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = NO;
    
//    JWUserModel *user = [JWUserModel userModel];
    
//    NSLog(@"user_icon %@--- user_nickName %@",user.user_icon,user.user_nickname);
    
    [self.mtTableView reloadData];
}





-(NSMutableDictionary *)dict{

    if(!_dict){
    
        _dict = [NSMutableDictionary  dictionary];
    
    }
    return _dict;

}

- (void)viewDidLoad {
    [super viewDidLoad];
    JWUserModel *user = [JWUserModel userModel];
    NSLog(@"%@",user.user_icon);
    self.view.backgroundColor = [UIColor yellowColor];
    
  
}





-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    JWUserModel *user = [JWUserModel userModel];

    
    if (indexPath.row == 0) {
            
            JWshowMeCell *cell = [JWshowMeCell showMeCellWithTableView:tableView];
            
            cell.nameLabel.text = @"头像";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
                
        [JWUpUserDataTools updataToUserAvatar:cell.icon HUDView:self.view];
       
        return cell;

    }else {
        
        
        JWShowMeTableViewCell *cell=[JWShowMeTableViewCell showMeTableViewCellWithTableView:tableView];
        
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
             if (indexPath.row==1){
            cell.staticLable.text = @"昵称";
                 cell.UserLable.text = user.user_nickname;
            } if (indexPath.row==2){
                 cell.staticLable.text = @"性别";
                cell.UserLable.text = user.user_sex;
            } if (indexPath.row==3){
            cell.staticLable.text=@"密码修改";
                cell.UserLable.text = @"pass**wor*";
            } if (indexPath.row==4){
            cell.staticLable.text=@"手机号码";
            cell.UserLable.text = user.user_tel;
        
            }if (indexPath.row==5){
                cell.staticLable.text=@"用户邮箱";
                cell.UserLable.text = user.user_email;
                
            }
        
        return cell;
     }
    
}




  




-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if ( indexPath.row==0) {
        return 100;
    }
    
    return 60;
}




-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      if (indexPath.row ==0) {
        
        JWUpLoadImageViewController *upLoadVC = [[JWUpLoadImageViewController alloc]initWithNibName:@"JWUpLoadImageViewController" bundle:nil];
        
        [self presentViewController:upLoadVC animated:YES completion:nil];
        
}
        if (indexPath.row == 1) {
            
            JWModeifyNickNameViewController *ModNickVC = [[JWModeifyNickNameViewController alloc]initWithNibName:@"JWModeifyNickNameViewController" bundle:nil];
            
            [self presentViewController:ModNickVC animated:YES completion:nil];
            
        }
    
    if (indexPath.row == 3) {
        
        JWModifyPassWordViewController *pwdVC = [[JWModifyPassWordViewController alloc] initWithNibName:@"JWModifyPassWordViewController" bundle:nil];
        
        [self presentViewController:pwdVC animated:YES completion:nil];
        
    }
}







-(IBAction)back {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
